<ResourceDictionary
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:MVVMSL="clr-namespace:Riba.MVVMSL"
>
	<Style TargetType="MVVMSL:NavigatorControl">
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="MVVMSL:NavigatorControl">
					<Border
						Background="{TemplateBinding Background}"
						BorderBrush="{TemplateBinding BorderBrush}"
						BorderThickness="{TemplateBinding BorderThickness}"
					>
						<VisualStateManager.VisualStateGroups>
							<VisualStateGroup x:Name="TransitionStates">
								<VisualState x:Name="Initial" />

								<VisualState x:Name="EndAnimationForward">
									<Storyboard>
										<DoubleAnimationUsingKeyFrames
											Storyboard.TargetName="ContentControl1" 
											Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationY)"
										>
											<EasingDoubleKeyFrame KeyTime="0" Value="0">
												<EasingDoubleKeyFrame.EasingFunction>
													<CircleEase EasingMode="EaseIn" />
												</EasingDoubleKeyFrame.EasingFunction>
											</EasingDoubleKeyFrame>
											<EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="90">
												<EasingDoubleKeyFrame.EasingFunction>
													<CircleEase EasingMode="EaseIn" />
												</EasingDoubleKeyFrame.EasingFunction>
											</EasingDoubleKeyFrame>
										</DoubleAnimationUsingKeyFrames>

										<DoubleAnimationUsingKeyFrames
											Storyboard.TargetName="ContentControl2"
											Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationY)"
										>
											<EasingDoubleKeyFrame KeyTime="0" Value="270">
												<EasingDoubleKeyFrame.EasingFunction>
													<CircleEase EasingMode="EaseOut" />
												</EasingDoubleKeyFrame.EasingFunction>
											</EasingDoubleKeyFrame>
											<EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="270">
												<EasingDoubleKeyFrame.EasingFunction>
													<CircleEase EasingMode="EaseOut" />
												</EasingDoubleKeyFrame.EasingFunction>
											</EasingDoubleKeyFrame>
											<EasingDoubleKeyFrame KeyTime="0:0:1" Value="360">
												<EasingDoubleKeyFrame.EasingFunction>
													<CircleEase EasingMode="EaseOut" />
												</EasingDoubleKeyFrame.EasingFunction>
											</EasingDoubleKeyFrame>
											<EasingDoubleKeyFrame KeyTime="0:0:1" Value="0">
												<EasingDoubleKeyFrame.EasingFunction>
													<CircleEase EasingMode="EaseOut" />
												</EasingDoubleKeyFrame.EasingFunction>
											</EasingDoubleKeyFrame>
										</DoubleAnimationUsingKeyFrames>

										<!--
											Workaround: A rotated Control may catch all mouse events even if it is invisible due to its rotation angle.
											They must not be made visible before animation, this is done automatically by the framework.
										-->
										<ObjectAnimationUsingKeyFrames
											Storyboard.TargetName="ContentControl1"
											Storyboard.TargetProperty="Visibility"
										>
											<DiscreteObjectKeyFrame KeyTime="0:0:1" Value="Collapsed" />
										</ObjectAnimationUsingKeyFrames>
									</Storyboard>
								</VisualState>

								<VisualState x:Name="EndAnimationBackward">
									<Storyboard>
										<DoubleAnimationUsingKeyFrames
											Storyboard.TargetName="ContentControl2"
											Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationY)"
										>
											<EasingDoubleKeyFrame KeyTime="0" Value="360">
												<EasingDoubleKeyFrame.EasingFunction>
													<CircleEase EasingMode="EaseIn" />
												</EasingDoubleKeyFrame.EasingFunction>
											</EasingDoubleKeyFrame>
											<EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="270">
												<EasingDoubleKeyFrame.EasingFunction>
													<CircleEase EasingMode="EaseIn" />
												</EasingDoubleKeyFrame.EasingFunction>
											</EasingDoubleKeyFrame>
										</DoubleAnimationUsingKeyFrames>

										<DoubleAnimationUsingKeyFrames
											Storyboard.TargetName="ContentControl1"
											Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationY)"
										>
											<EasingDoubleKeyFrame KeyTime="0" Value="90">
												<EasingDoubleKeyFrame.EasingFunction>
													<CircleEase EasingMode="EaseOut" />
												</EasingDoubleKeyFrame.EasingFunction>
											</EasingDoubleKeyFrame>
											<EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="90">
												<EasingDoubleKeyFrame.EasingFunction>
													<CircleEase EasingMode="EaseOut" />
												</EasingDoubleKeyFrame.EasingFunction>
											</EasingDoubleKeyFrame>
											<EasingDoubleKeyFrame KeyTime="0:0:1" Value="0">
												<EasingDoubleKeyFrame.EasingFunction>
													<CircleEase EasingMode="EaseOut" />
												</EasingDoubleKeyFrame.EasingFunction>
											</EasingDoubleKeyFrame>
										</DoubleAnimationUsingKeyFrames>

										<!-- See workaround in EndAnimationForward -->
										<ObjectAnimationUsingKeyFrames
											Storyboard.TargetName="ContentControl2"
											Storyboard.TargetProperty="Visibility"
										>
											<DiscreteObjectKeyFrame KeyTime="0:0:1" Value="Collapsed" />
										</ObjectAnimationUsingKeyFrames>
									</Storyboard>
								</VisualState>
							</VisualStateGroup>
						</VisualStateManager.VisualStateGroups>

						<Grid>
							<ContentControl x:Name="ContentControl1" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch">
								<ContentControl.Projection>
									<PlaneProjection />
								</ContentControl.Projection>
							</ContentControl>

							<ContentControl x:Name="ContentControl2" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch">
								<ContentControl.Projection>
									<PlaneProjection />
								</ContentControl.Projection>
							</ContentControl>
						</Grid>
					</Border>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>

	<Style TargetType="MVVMSL:ViewEventHandlerControl">
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="MVVMSL:ViewEventHandlerControl">
					<Border
						Background="{TemplateBinding Background}"
						BorderBrush="{TemplateBinding BorderBrush}"
						BorderThickness="{TemplateBinding BorderThickness}">
					</Border>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>
</ResourceDictionary>
